package il.technion.cs236369.webserver.typeHandlers;

import il.technion.cs236369.interfaces.ICookie;

/**
 * A cookie implementation that uses a long identifier
 * 
 * @author Gal Lalouche
 * 
 */
class CookieImpl implements ICookie {
	private final long	cookie;

	/**
	 * Create a new Cookie, using a string as an identifier
	 * 
	 * @param i
	 */
	public CookieImpl(long i) {
		super();

		this.cookie = i;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int)(cookie ^ (cookie >>> 32));
		return result;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		CookieImpl other = (CookieImpl)obj;
		if (cookie != other.cookie)
			return false;
		return true;
	}

	@Override
	public String getName() {
		return "TSPCookie";
	}

	@Override
	public String getValue() {
		return cookie + "";
	}

}
